Static arrays (ARRAY) are declared using the same method as used for variables, except that a series of storage locations is allocated for the array values, rather than a single location typical of a variable. Static array declarations occur in the
VAR block along with other variables.
In the array declaration, the term [m..n] indicates the dimension, or size, of the array. An array declared with a dimension of
[1..10] will allocate ten contiguous storage locations in memory. Static arrays support any valid fundamental data type, as well as the user-defined
STRUCTURE type (see
Creating Structures for details).
To retrieve a value from an element of a one-dimensional array, the same bracket notation described earlier is used. The array name should appear to the left of the brackets, and a non-negative
INTEGER value representing the array index should appear within the brackets:
An array index may be any constant non-negative INTEGER value or expression which resolves to such a value.
In the example, a ten element array of STRING is declared, and the script code begins with assignment of values to the elements of the array. In the assignments, constants are used to represent the array indices, but a variable or other identifier which evaluates to an
INTEGER value could have been used in their place. Such an identifier is used later in the
Concat() function call to reference array elements.
In the declaration for the two-dimensional array, the first index value defines the number of “rows” in the array, while the second index defines the number of “columns.” In such a two-dimensional array,
n x
s contiguous storage locations will be allocated to hold data values (when
m and
r are 1).